// MainWindow.h
//
// MainWindow: abstract window class.
// It can be derived into Attached or Frame (that are QT windows)
//
// Parent child - relations between windows
//	
//	           MainWindow
//	        _______|______
//	       |              |
//	       v              v
//	   AttachedWindow   FrameWindow
//	       |_______ ______|
//	               |
//	               v
//	             GLArea
#pragma once

#include "ViewInterface/ViewSettings.h"
#include "ViewInterface/ViewGraphic.h"
#include "src/ViewOpenGL.h"


namespace IDS{
namespace IDEAS{
namespace OpenGLView{
	class GraphicScene;
namespace Fwk {
// forward declaration
class GLFrame;

class MainWindow
{
public:
	enum WindowType { EmbeddedType, StandAloneType };
	enum DockType   { DOCKTOP,DOCKLEFT,DOCKBOTTOM,DOCKRIGHT };
	
	//enum ToolBar    {
	//NoToolBar   = 0x00,	
	//MainToolBar = 0x01,
	//EditToolBar = 0x02,
	//AllToolbars = 0xFF
	//};

protected:
	int windowWidth;
	int windowHeight;

	GLFrame		*glArea;
	ViewInterface::ViewGraphic	*view;
	bool showProgressBar;

	virtual void _init_createActions()  {}
	virtual void _init_createMenus()    {}
	virtual void _init_createToolBars() {}

	virtual void _deinit_destroyActions()	{}
	virtual void _deinit_destroyMenus()		{}
	virtual void _deinit_destroyToolBars()	{}

public:
	struct ClientSize
	{
		int width;
		int height;
	};

	// Constructor
	MainWindow(ViewInterface::ViewGraphic *owner);
	virtual ~MainWindow();

	virtual bool preInitializations();
	virtual bool postInitializations();

	virtual void	sendEventToApp(ViewInterface::ViewEventBase *event);
	//virtual void	sendEventToApp(ViewInterface::Event<ViewInterface::ViewEventHandler> *event);
	virtual std::string getResourceDir();
	virtual ViewInterface::ViewOpenGLQT *getView()  {return (ViewInterface::ViewOpenGLQT *)view;}
	virtual BaseGeometry::MetricType getMetric()   {return view->getMetric();}
	//virtual GLFrame	       *getGLArea()		       {return glArea;}
	virtual ViewInterface::ViewGraphic::Status	getSceneStatus();
	OpenGLView::GraphicScene *getScene();

	virtual void setBackgroundColor( const ViewInterface::Color &bk );
	virtual void setBackgroundColor( const ViewInterface::Color &top, const ViewInterface::Color &btm );

	virtual void setSceneStatus(ViewInterface::ViewOpenGLQT::Status s);
	virtual void setSceneSettings(ViewInterface::GraphicsViewSettings *settings);
	virtual void setWindowTitle(const std::string &title) {}
	virtual void setStatusMessage(const std::string &status) {}
	virtual void setStatusPosition(const IDSReal2D &chartPoint, const IDSReal2D &geoPoint, double elevation) {}
	virtual void setStatusPercentage(double percent) {}
	virtual void setWindowSize(int x, int y, int w, int h){}
	virtual void showToolbars() {}
	virtual void showWindow() {}
	virtual void setCursor(unsigned int cursorID) {}
	virtual ClientSize getClientSize() { return ClientSize();}

	virtual bool insertObjects(const std::vector<ViewInterface::ViewObject*> &objs);
	virtual bool insertObject(const ViewInterface::ViewObject& vobj);
	virtual bool removeObjects(const std::vector<ViewInterface::Identifier> &objs);
	virtual bool removeObject(const ViewInterface::Identifier &);
	virtual bool removeAllDomainObjects();
	virtual void removeAllLocalObjects();
	virtual bool refreshLocalObjects();
	virtual void startClipMode(ViewInterface::Identifier imgID);

	virtual void hilightObjects(const std::vector<ViewInterface::Identifier>& objs);
	virtual void selectObjects(const std::vector<ViewInterface::Identifier>& objs);

	virtual void redraw();
	virtual void fitView();
	virtual void fitView(const IDSBox &upperLeftBottomRight);
	virtual void fitView(const ViewInterface::Identifier &id);

	virtual WindowType getWindowType() = 0;
	virtual void dockWindow(void *window, void *action, DockType dock) = 0;
};



}}}}